package com.apigen.platform.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.Builder;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;

/**
 * API端点视图对象
 *
 * @author API Generator Platform
 * @since 2024-09-24
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "API端点信息")
public class ApiEndpointVO {

    @Schema(description = "端点ID", example = "1")
    private Long endpointId;

    @Schema(description = "端点名称", example = "获取用户列表")
    private String endpointName;

    @Schema(description = "端点路径", example = "/api/users")
    private String endpointPath;

    @Schema(description = "HTTP方法", example = "GET")
    private String httpMethod;

    @Schema(description = "关联表ID", example = "1")
    private Long tableId;

    @Schema(description = "关联表名", example = "sys_user")
    private String tableName;

    @Schema(description = "表描述", example = "系统用户表")
    private String tableComment;

    @Schema(description = "端点描述", example = "分页获取用户列表")
    private String description;

    @Schema(description = "启用分页", example = "true")
    private Boolean enablePagination;

    @Schema(description = "启用排序", example = "true")
    private Boolean enableSorting;

    @Schema(description = "启用筛选", example = "true")
    private Boolean enableFiltering;

    @Schema(description = "响应格式", example = "JSON")
    private String responseFormat;

    @Schema(description = "所属项目ID", example = "1")
    private Long projectId;

    @Schema(description = "所属项目名称", example = "用户管理系统")
    private String projectName;

    @Schema(description = "创建者ID", example = "1000")
    private Long creatorId;

    @Schema(description = "创建者名称", example = "admin")
    private String creatorName;

    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    private LocalDateTime updateTime;

    @Schema(description = "请求参数列表")
    private List<ApiParameterVO> requestParameters;

    @Schema(description = "响应字段列表")
    private List<ApiFieldVO> responseFields;

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @Schema(description = "API参数信息")
    public static class ApiParameterVO {

        @Schema(description = "参数名称", example = "username")
        private String paramName;

        @Schema(description = "参数类型", example = "String")
        private String paramType;

        @Schema(description = "参数位置", example = "QUERY")
        private String paramLocation;

        @Schema(description = "是否必填", example = "false")
        private Boolean required;

        @Schema(description = "参数描述", example = "用户名筛选条件")
        private String description;

        @Schema(description = "默认值", example = "")
        private String defaultValue;

        @Schema(description = "示例值", example = "admin")
        private String exampleValue;
    }

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @Schema(description = "API字段信息")
    public static class ApiFieldVO {

        @Schema(description = "字段名称", example = "userId")
        private String fieldName;

        @Schema(description = "字段类型", example = "Long")
        private String fieldType;

        @Schema(description = "是否包含在响应中", example = "true")
        private Boolean included;

        @Schema(description = "字段描述", example = "用户ID")
        private String description;

        @Schema(description = "示例值", example = "1000")
        private String exampleValue;
    }
}











